﻿#region Copyright (C) Sector7 Software Studio. All rights reserved
/*******************************************************************************************
 * Creation
 *      Author:         Wolf Lai
 *      Date:           2013/5/21 星期二 23:25:25
 *      Version:        
 * Modification 
 *      Author: 
 *      Date: 
 *      Description: 
 *      Version:
 *******************************************************************************************/
#endregion
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data.SqlClient;
using Sector7.Framework.DB;
using System.Data;

namespace Sector7.Medical.DAO.Standard
{
    /// <summary>
    /// 流水号数据访问对象
    /// </summary>
    public class SeedDAO : ISeedDAO
    {
        #region Public functions

        public int ReadUnarySeed(string arg1)
        {
            string sql = "MP_GetUnarySeed";

            using (DBHelper helper = new DBHelper())
            {
                SqlParameter seed = DBUtil.CreateDirectionParameter(
                    "@ReturnValue",
                    DbType.Int32,
                    ParameterDirection.ReturnValue);
                helper.ExecuteStoredProcedureNonQuery(sql,
                    DBUtil.CreateSqlParameter(arg1, "Arg1"),
                    seed);

                return Convert.ToInt32(seed.Value);
            }
        }

        public int ReadBinarySeed(string arg1, string arg2)
        {
            string sql = "MP_GetBinarySeed";

            using (DBHelper helper = new DBHelper())
            {
                SqlParameter seed = DBUtil.CreateDirectionParameter(
                    "@ReturnValue",
                    DbType.Int32,
                    ParameterDirection.ReturnValue);
                helper.ExecuteStoredProcedureNonQuery(sql,
                    DBUtil.CreateSqlParameter(arg1, "Arg1"),
                    DBUtil.CreateSqlParameter(arg2, "Arg2"),
                    seed);

                return Convert.ToInt32(seed.Value);
            }
        }

        public int ReadTernarySeed(string arg1, string arg2, string arg3)
        {
            string sql = "MP_GetTernarySeed";

            using (DBHelper helper = new DBHelper())
            {
                SqlParameter seed = DBUtil.CreateDirectionParameter(
                    "@ReturnValue",
                    DbType.Int32,
                    ParameterDirection.ReturnValue);
                helper.ExecuteStoredProcedureNonQuery(sql,
                    DBUtil.CreateSqlParameter(arg1, "Arg1"),
                    DBUtil.CreateSqlParameter(arg2, "Arg2"),
                    DBUtil.CreateSqlParameter(arg3, "Arg3"),
                    seed);

                return Convert.ToInt32(seed.Value);
            }
        }

        #endregion
    }
}
